package sardine;

import sardine.function.Filter;

import java.util.Objects;

/**
 * @auth bruce-sha
 * @date 2015/5/21
 */
public abstract class SimpleFilter implements Filter {

    private final String path;
    private final String acceptType;

    protected SimpleFilter() {
        this(SardineBase.ALL_PATHS);
    }

    protected SimpleFilter(final String path) {
        this(path, SardineBase.DEFAULT_CONTENT_TYPE);
    }

    protected SimpleFilter(final String path, final String acceptType) {
        this.path = Objects.requireNonNull(path);
        this.acceptType = Objects.requireNonNull(acceptType);
    }

    public String getAcceptType() {
        return acceptType;
    }

    public String getPath() {
        return this.path;
    }

    public abstract void apply(Request request, Response response) throws Exception;
}